package com.wuxi.zhang.controller;

import com.alibaba.fastjson.JSONObject;
import com.wuxi.zhang.base.result.Result;
import com.wuxi.zhang.base.result.ResultUtil;
import com.wuxi.zhang.bean.UserBean;
import com.wuxi.zhang.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by zhang on 2018/8/3.
 */
@Controller
public class TestController {

    @Autowired
    TestService service;

    @RequestMapping("/test/getuser")
    @ResponseBody
    public Result queryUser(){
        List<UserBean> listBean = service.queryUser();
        //int a = 1 / 0;
        return ResultUtil.success(listBean);
    }

    @RequestMapping("/test/hello")
    public String hello(Model model) {
        model.addAttribute("name", "world");
        return "hello";
    }
}
